<?=$this->header(true)?>


    <?=$this->menu("contacts")?>


    <h1><?=$this->message("label.header", _Contact::BUNDLE)?></h1>


    <? /* Breadcrums route */ ?>
    <?=$this->route(
        array(
            array(
                "name"=>$this->message("label.header", _Contact::BUNDLE),
                "href"=>"contact/index"
            ),
            array(
                "name"=>($this->contactForm->getContact()->getContactId() > 0 ?
                    $this->message("route.edit", _Core::BUNDLE) . " " .
                        "\"".$this->contactForm->getContact()->getFirstname()." ".
                        $this->contactForm->getContact()->getSurname()."\" " :
                    $this->message("route.new", _Core::BUNDLE) . " " .$this->message("label.item", _Contact::BUNDLE))
            )
        )
    )?>


    <? /* Show error messages */ ?>
    <?=$this->errors(null, _Contact::BUNDLE)?>


    <form id="<?=get_class($this->contactForm)?>" action="contact/save" method="post" enctype="multipart/form-data">

        <div>
            <input type="hidden"
                   name="contact->contactId"
                   value="<?=$this->contactForm->getContact()->getContactId()?>" />
        </div>

        <fieldset>

            <legend><?=$this->message("label.required", _Core::BUNDLE)?></legend>

            <table cellspacing="0" cellpadding="0" class="form">
            <tr class="ctrl<?=$this->error("contact->firstname")?>">
                <th><label for="contact_firstname"><?=$this->message("prompt.firstname", _Contact::BUNDLE)?></label></th>
                <th class="required"><em>*</em></th>
                <td>
                    <input name="contact->firstname"
                           id="contact_firstname"
                           value="<?=$this->contactForm->getContact()->getFirstname()?>"
                           maxlength="32"
                           type="text"
                           class="textInput" />
                </td>
            </tr>
            <tr class="ctrl<?=$this->error("contact->surname")?>">
                <th><label for="contact_surname"><?=$this->message("prompt.surname", _Contact::BUNDLE)?></label></th>
                <th class="required"><em>*</em></th>
                <td>
                    <input name="contact->surname"
                           id="contact_surname"
                           value="<?=$this->contactForm->getContact()->getSurname()?>"
                           maxlength="32"
                           type="text"
                           class="textInput" />
                </td>
            </tr>
            <tr class="ctrl<?=$this->error("contact->email")?>">
                <th><label for="contact_email"><?=$this->message("prompt.email", _Contact::BUNDLE)?></label></th>
                <th class="required"><em>*</em></th>
                <td>
                    <input name="contact->email"
                           id="contact_email"
                           value="<?=$this->contactForm->getContact()->getEmail()?>"
                           maxlength="32"
                           type="text"
                           class="textInput" />
                </td>
            </tr>
            <tr class="ctrl<?=$this->error("contact->phone")?>">
                <th><label for="contact_phone"><?=$this->message("prompt.phone", _Contact::BUNDLE)?></label></th>
                <th class="required"><em>*</em></th>
                <td>
                    <input name="contact->phone"
                           id="contact_phone"
                           value="<?=$this->contactForm->getContact()->getPhone()?>"
                           maxlength="32"
                           type="text"
                           class="textInput" />
                </td>
            </tr>
            <tr class="ctrl<?=$this->error("contact->office")?>">
                <th><label for="contact_office"><?=$this->message("prompt.office", _Contact::BUNDLE)?></label></th>
                <th class="required"><em>*</em></th>
                <td>
                    <input name="contact->office"
                           id="contact_office"
                           value="<?=$this->contactForm->getContact()->getOffice()?>"
                           maxlength="32"
                           type="text"
                           class="textInput" />
                </td>
            </tr>
            <tr class="ctrl<?=$this->error("contact->role")?>">
                <th><label for="contact_role"><?=$this->message("prompt.role", _Contact::BUNDLE)?></label></th>
                <th class="required"><em>*</em></th>
                <td>
                    <input name="contact->role"
                           id="contact_role"
                           value="<?=$this->contactForm->getContact()->getRole()?>"
                           maxlength="32"
                           type="text"
                           class="textInput" />
                </td>
            </tr>
            </table>

        </fieldset>


        <fieldset>

            <legend><?=$this->message("label.optional", _Core::BUNDLE)?></legend>

            <table cellspacing="0" cellpadding="0" class="form">
            <tr class="ctrl<?=$this->error("contact->fax")?>">
                <th><label for="contact_fax"><?=$this->message("prompt.fax", _Contact::BUNDLE)?></label></th>
                <th class="required"><em>&nbsp;</em></th>
                <td>
                    <input name="contact->fax"
                           id="contact_fax"
                           value="<?=$this->contactForm->getContact()->getFax()?>"
                           maxlength="32"
                           type="text"
                           class="textInput" />
                </td>
            </tr>
            <tr class="ctrl<?=$this->error("formImage")?>">
                <th><label for="formImage"><?=$this->message("label.image", _Core::BUNDLE)?></label></th>
                <th class="required"><em>&nbsp;</em></th>
                <td>
                    <? if(!is_null($this->contactForm->getContact()) &&
                        $this->contactForm->getContact()->getImageId() > 0 &&
                        !is_null($this->contactForm->getContact()->getImageRelatedByImageId())) { ?>

                        <input type="hidden"
                               name="contact->imageRelatedByImageId->imageId"
                               value="<?=$this->contactForm->getContact()->getImageId()?>" />
                        <input type="hidden"
                               name="contact->imageRelatedByThumbnailId->imageId"
                               value="<?=$this->contactForm->getContact()->getThumbnailId()?>" />

                        <input type="hidden"
                               name="contact->imageRelatedByImageId->binaryFileId"
                               value="<?=$this->contactForm->getContact()->getImageRelatedByImageId()->getBinaryFileId()?>" />
                        <input type="hidden"
                               name="contact->imageRelatedByThumbnailId->binaryFileId"
                               value="<?=$this->contactForm->getContact()->getImageRelatedByThumbnailId()->getBinaryFileId()?>" />

                        <img src="image?id=<?=$this->contactForm->getContact()->getImageId()?>"
                             width="<?=$this->contactForm->getContact()->getImageRelatedByImageId()->getWidth()?>"
                             height="<?=$this->contactForm->getContact()->getImageRelatedByImageId()->getHeight()?>" alt="" />

                        <input type="checkbox" name="deleteImage" value="true" id="deleteImage" /> <label for="deleteImage"><?=$this->message("label.image.delete", _Core::BUNDLE)?></label>

                        <br /><br />

                    <? } ?>

                    <input type="file" name="formImage" />

                    <? if(!is_null($this->param(_Contact::SETTINGS))): ?>
                    <p class="hint"><?=$this->message("note.image.resize", _Core::BUNDLE)?> <?=$this->imageProps($this->param(_Contact::SETTINGS))->getImageWidth()?>x<?=$this->imageProps($this->param(_Contact::SETTINGS))->getImageHeight()?>.</p>
                    <? endif; ?>

                </td>
            </tr>
            </table>

        </fieldset>


        <div class="buttons">

            <input type="button"
                   onclick="to('contact/index')"
                   value="<?=$this->message("button.cancel", _Core::BUNDLE)?>"
                   class="button" />
            <input type="submit"
                   value="<?=$this->message("button.submit", _Core::BUNDLE)?>"
                   class="button" />

        </div>

    </form>

<?=$this->footer()?>